#include "CObject.h"

CCObject::CCObject(void)
	:pRect(NULL),
	pSurface(NULL),
	fScale(1.0f),
	fRotate(0.0f)
{
}

CCObject::~CCObject( void )
{
	if (this->pSurface != NULL)
	{
		SDL_FreeSurface(this->pSurface);
	}
	if (this->pRect)
	{
		delete this->pRect;
	}
}

void CCObject::setRect( float x, float y, float width, float height )
{
	if (!this->pRect)
	{
		pRect = new SDL_Rect;
	}
	pRect->x = x;
	pRect->y = y;
	pRect->w = width;
	pRect->h = height;
}

void CCObject::setScale( float scale )
{
	this->fScale = scale;
}

void CCObject::setRotate( float angle )
{
	this->fRotate = angle;
}

SDL_Surface * CCObject::drawable()
{
	return this->pSurface;
}

SDL_Rect * CCObject::drawRect()
{
	
	if (this->pRect != NULL)
	{
		if (this->fScale > 0.000001)
		{
			this->pRect->w *= this->fScale;
			this->pRect->h *= this->fScale;
		}
	}
	return this->pRect;
}



